<?php

/**
 * ClienteController
 * 
 * @package Sgit 
 * @author Juan Manuel Martinez Carrillo
 * @copyright Juan Manuel Martinez Carrillo
 * @version 2012
 * @access public
 * @revision 17/02/2012 8:53:55
 */

class ClienteController extends Sgit_Controller_Action
{
    protected $_checkZona = true;
    protected $_checkAcceso = false;
    
    protected $_main_model = 'cliente';
    protected $_main_form = 'Cliente';


    public function inserttableAction()
    {
        //$this->_helper->layout->disableLayout();
        $this->_helper->viewRenderer->setNoRender(TRUE);
        
        $proyectos=new Application_Model_Proyectos();
        $clientes=new Application_Model_Clientes();
        $cli=new Application_Model_Cliente();
        $cli->alter();
        
        $where['id_zona=?']=$this->_idZona;
        $where['activo=?']=1;
        
        
        $rows=$proyectos->getAll($where,null,'orden');
        
      
        foreach($rows as $k => $v)
        {
            $rows[$k]['cliente']=$clientes->getRow($v['id_cliente']);
            
            $cliente['razon_social']=$rows[$k]['cliente']['raz_soc'];
            $cliente['nombre']=$rows[$k]['cliente']['nombre'];
            $cliente['cif']=$rows[$k]['cliente']['nif'];
            $cliente['direccion']=$rows[$k]['cliente']['doc_soc'];

            $cliente['pep']=$rows[$k]['orden'];
            $cliente['id_sector']=$rows[$k]['id_sector'];
            $cliente['id_zona']=$rows[$k]['id_zona'];
            $cliente['id_jp']=$rows[$k]['id_dir'];

            
            $cli->insertRow($cliente);
          
        }
    }


}
